# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QFileDialog
from views.demo0401 import Ui_Form
from views.demo0402 import Ui_MainWindow


class MainForm(QMainWindow, Ui_MainWindow):

    def __init__(self):
        super(MainForm, self).__init__()
        self.setupUi(self)

        self.child = ChildrenForm()

        self.fileCloseAction.triggered.connect(self.close)
        self.fileOpenAction.triggered.connect(self.openMsg)
        self.addWinAction.triggered.connect(self.childShow)

    def openMsg(self):
        file, ok = QFileDialog.getOpenFileName(self, "打开", "G:/", "All Files (*);;Text Files (*.txt)")
        self.statusbar.showMessage(file)

    def childShow(self):
        self.gridLayout.addWidget(self.child)
        self.child.show()

class ChildrenForm(QWidget, Ui_Form):
    def __init__(self):
        super(ChildrenForm, self).__init__()
        self.setupUi(self)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainForm()
    win.show()
    sys.exit(app.exec())